class Solution:
    def rotate(self, nums, k):
        n = len(nums)
        nums[:n-k] = nums[:n-k][::-1]
        nums[n-k:n] = nums[n-k:n][::-1]
        nums[:] = nums[::-1]
a = [1,2,3,4,5,6,7] #[4,3,2,1,5,6,7] => [4,3,2,1,7,6,5] => [5,6,7,1,2,3,4]
Solution().rotate(a, 3)
print a
